home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CTerminalPane 1.0 / CTerminalPane.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  3.2 KB  |  113 lines  |  [TEXT/KAHL]

  1. /*
  2. ** CTerminalPane.h
  3. **
  4. **    Eric’s standard libraries
  5. **    Terminal display pane
  6. **
  7. **    Copyright © 1993, FrostByte Design / Eric Scouten
  8. **    Portions copyright © 1990 Symantec Corporation. All rights reserved.
  9. */
  10.  
  11.  
  12. #pragma once
  13. #include <CPanorama.h>
  14.  
  15. /*
  16. **    This class provides a rudimentary terminal emulator. It’s nothing
  17. **    fancy or snazzy. It doesn’t do VT100; it doesn’t do scrollback;
  18. **    it doesn’t handle any kind of formatting. (NCSA won’t be jealous,
  19. **    in other words.)
  20. */
  21.  
  22. /*
  23. ** These constants define the terminal size. You may change them here. With a little
  24. ** work, these parameters could be changed on the fly. But I haven’t been so ambitious. :-P
  25. */
  26.  
  27. #define maxX                80                    /* width of screen */
  28. #define maxY                24                    /* height of screen */
  29.  
  30. #define pixelsX                6                    /* default font char width (Monaco 9) */
  31. #define pixelsY                11                    /* default font char height */
  32.  
  33. #define offsetX                4                    /* horizontal offset from screen edge */
  34. #define offsetY                4                    /* vertical offset from screen edge */
  35.  
  36. #define sizeX                488                    /* 80 columns * 6 pixels + 8 margin */
  37. #define sizeY                272                    /* 24 rows * 11 pixels + 8 margin */
  38.  
  39. // define the characters we will recognize
  40.  
  41. #define charNUL            0                    /* Telnet standard keycodes */
  42. #define charBEL            7
  43. #define charBS                8
  44. #define charHT                9
  45. #define charLF                10
  46. #define charVT                11
  47. #define charFF                12
  48. #define charCR                13
  49. #define charDEL            127
  50.  
  51.  
  52. // class definition
  53.  
  54.  
  55. class CTerminalPane : public CPanorama {
  56.  
  57. protected:
  58.     char        theScreen[maxY][maxX];                /* contents of the screen */
  59.     short    theColumn;                        /* terminal cursor column number */
  60.     short    theLine;                            /* terminal cursor line number */
  61.     Boolean    blinkCursor;                        /* cursor blinking is enabled */
  62.     Boolean    cursorVis;                        /* cursor is inverted */
  63.     short    lastCursorCol;                        /* position of displayed cursor */
  64.     short    lastCursorLine;
  65.     long        lastCursorTick;                        /* time at last cursor flash */
  66.  
  67.     
  68.     /* contruction/destruction */
  69.     
  70. public:
  71.     void ITerminalPane (CView *anEnclosure, CBureaucrat *aSupervisor,
  72.                     short aWidth, short aHeight, short aHEncl, short aVEncl,
  73.                     SizingOption aHSizing, SizingOption aVSizing);
  74.  
  75.     /* drawing */
  76.     
  77.     virtual void Draw (Rect *area);
  78.     
  79.     /* blinking cursor support */
  80.     
  81.     virtual void Dawdle (long *maxSleep);
  82.     virtual Boolean BecomeGopher (Boolean fBecoming);
  83.     virtual void SetBlinking (Boolean blinkMode);
  84.  
  85.     /* scrolling */
  86.     
  87.     virtual void ScrollToSelection (void);
  88.     
  89.     /* terminal emulation methods */
  90.     
  91.     virtual void DoClearScreen (void);
  92.     virtual void DoWriteChar (char theChar);
  93.     virtual void DoWriteStr (char *theStr);
  94.     virtual void DoWriteBfr (char *theStr, short theSize);
  95.     virtual void DoWriteCharNum (char theChar, char leftBracket, char rightBracket);
  96.     virtual void DoEraseChar (void);
  97.     virtual void DoEraseLine (void);
  98.     
  99.     /* private screen handling methods */
  100.     
  101. protected:
  102.     virtual void ClearToEOL (short col, short line);
  103.     virtual void ClearToEOS (short col, short line);
  104.     virtual void ScrollTerm (void);
  105.     virtual void InvalCharRect (short left, short top,
  106.                     short right, short bottom);
  107.     virtual void CursorMoved (void);
  108.     virtual void CalcCharRect (short left, short top, short right,
  109.                     short bottom, LongRect *theRect);
  110.     virtual void InvertCursor (short col, short line);
  111.  
  112. };
  113.